package L7.L713;

import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 比较版本号
 *
 * @author: luolidong
 * @create: 2021-07-14 09:51
 * @version: 1.0
 */
public class Version {
    public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        System.out.println(Arrays.toString(v1));
        System.out.println(Arrays.toString(v2));
        int i = 0;
        while (i < v1.length && i < v2.length) {
            int i1 = Integer.parseInt(v1[i]);
            int i2 = Integer.parseInt(v2[i]);

            if (i1 > i2) {
                return 1;
            } else if (i1 < i2) {
                return -1;
            }
            i++;
        }
        if (i < v1.length) {
            while (i < v1.length) {
                if (Integer.parseInt(v1[i]) != 0) {
                    return 1;
                }
                i++;
            }
        } else if (i < v2.length) {
            while (i < v2.length) {
                if (Integer.parseInt(v2[i]) != 0) {
                    return -1;
                }
                i++;
            }
        }
        return 0;

    }

    public static void main(String[] args) {
        Version version = new Version();
        int i = version.compareVersion("0.01.01", "0.02.001.3");
        System.out.println(i);

        char a=90;
        System.out.println(a);
        Map<Character,Integer> map=new HashMap<>();
        for (int j = 65; j <= 90; j++) {
            map.put((char)j, j-64);
        }


    }
}
